//1.公用样式
require('../../assets/css/index.js')
//当前页面样式
require('./mine.less')

//2.公用js
let dom = require('../../utils/dom.js');
let https = require('../../utils/https.js');
let local = require('../../utils/local.js');


 //判定进入我的页面的时候 是否已经登录，未登录 弹到登录页面 
https.isLogin()
//3.当前页面效果
// console.log(dom);
//相当于文档加载事件
dom.ready(function () {
let userName=dom.getById('.userName');
let signature=dom.getById('.signature');
<<<<<<< HEAD
<<<<<<< HEAD
let Clockcount=dom.getById('.ClockCount');
let avatar=dom.getById('.avatar');
    dom.click('mine');

=======
let Clockcount=dom.getById('#ClockCount');
let punchtodayBtn=dom.getById('#punchtodayBtn');
let headPic=dom.getById('.headPic');

    dom.click('mine');

>>>>>>> wl
=======
let Clockcount=dom.getById('#ClockCount');
let punchtodayBtn=dom.getById('#punchtodayBtn');
let headPic=dom.getById('.headPic');

    dom.click('mine');

>>>>>>> wl
    // 数据渲染函数 
    function render(){
    let Info=local.get('Info')
    console.log(Info);
    let {nickName,clockCount,imgUrl,sign}=Info;
    userName.textContent=nickName;
<<<<<<< HEAD
<<<<<<< HEAD
    // signature.textContent=sign;
    // Clockcount.textContent=clockCount;


    } 
  

    render()
=======
=======
>>>>>>> wl
    signature.textContent=sign;
    Clockcount.textContent=clockCount;
    // 加载图片需要src   图片路径名字不完整
    headPic.src=https.BASE_URL+imgUrl;
   
    } 
  

    render();
    
<<<<<<< HEAD
>>>>>>> wl
=======
>>>>>>> wl

        // 点击事件
        let PersonalData = dom.getById('#PersonalData');
        PersonalData.addEventListener('click', function () {
              window.location.href = 'Inforrevise.html'
              })
})

     




//     let PersonalData = dom.getById('#PersonalData');
//     let MotionData = dom.getById('#MotionData');
//     let SportsBadge = dom.getById('#SportsBadge');
//     let userName = document.querySelector('.userName');
//     PersonalData.addEventListener('click', function () {
//         window.location.href = 'Inforrevise.html'
//     })
//     MotionData.addEventListener('click', function () {
//         window.location.href = 'Motiondata.html'
//     })
//     SportsBadge.addEventListener('click', function () {
//         window.location.href = 'Sportsbadge.html'
//     })

//     https.get('/api/user/info', function (res) {
//         console.log(res);
//         if (res.errno == 0) {
//             local.set('userInfo', res.data);
//             userName.textContent = res.data.nickName;
//             ClockCount.textContent = res.data.clockCount;
//             Duration.textContent = res.data.duration;
//             Calorie.textContent = res.data.calorie;
//         }
//     })

//     function getclockInfo() {
//         https.get('/api/user/clockInInfo', function (res) {
//             if (res.errno == 0) {
//                 console.log(res);
//                 ClockCount.textContent = res.data.clockCount;
//                 Btn.textContent = res.data.isClockIn ? "已经打卡" : "今日打卡"
//             }
//         })
//     }

//     getclockInfo()

// Btn.addEventListener('click',function(){
//     https.post('/api/user/clockIn',{},function(res){
//         console.log(res);

//         //判定
//         if(res.errno==0){//打卡成功
//             weui.topTips(res.message)
//             //渲染
//             getclockInfo()
//         }else if(res.errno==-1){//已经打过卡了
//             weui.topTips(res.message)
//         }else{//报错了
//             weui.topTips(res.message)
//         }
        
//       })
// })











